import 'package:boss/ui/widget/image/base_image.dart';
import 'package:boss/ui/widget/qr/qr_scan.dart';
import 'package:flutter/material.dart';
import 'package:hi_common/hi_common.dart';

class ScanIcon extends StatelessWidget {
  final ValueChanged<String> onScan;
  final EdgeInsets padding;

  const ScanIcon({
    Key key,
    this.onScan,
    this.padding = EdgeInsets.zero,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () async {
        final res = await showScanPage(context);

        if (res != null) {
          onScan(res);
        }
      },
      child: Padding(
        padding: padding,
        child: BaseImage(
          'assets/image/scan_icon.png',
          width: 34.w,
          height: 34.w,
        ),
      ),
    );
  }
}
